package com.tanhua.model.vo;

import com.tanhua.model.mongo.Questionnaire;
import com.tanhua.model.mongo.UsersScore;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.util.List;

//vo
@Data
@AllArgsConstructor
@NoArgsConstructor
public class QuestionnaireVo {
    private String id;
    private String name;
    private String cover;
    private String level;
    private Integer star;

    private List<QuestionsVo> questions;

    private Integer isLock;
    private String reportId;

    public static QuestionnaireVo init(List<QuestionsVo> questionVo, UsersScore usersScore, Questionnaire questionnaire){
        QuestionnaireVo vo = new QuestionnaireVo();
        BeanUtils.copyProperties(questionnaire,vo);
        //vo.setId(questionnaire.getId().toString());
        if (usersScore!=null){
            BeanUtils.copyProperties(usersScore,vo);
        }

        if (usersScore!=null && usersScore.getId()!=null){
            vo.setReportId(usersScore.getId().toString());
        }
        vo.setQuestions(questionVo);
        return vo;
    }

}
